/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ButtonStuff.java
 *
 * Created on May 31, 2009, 12:14:36 PM
 */

package GeneralTesting;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
import java.util.Random;
import javax.swing.JLabel;

/**
 *
 * @author Heather
 */
public class ButtonStuff extends javax.swing.JApplet {

    /** Initializes the applet ButtonStuff */
    public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();
                    Color c1 = new Color(0, 0, 0);
                    Color c2 = new Color(100, 100, 100);
                    thePanel.setBackground(c1);
                    jButton3.setBackground(c2);
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    thePanel = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    theLabel = new javax.swing.JLabel();
    jButton3 = new javax.swing.JButton();
    jTextField1 = new javax.swing.JTextField();
    jCheckBox1 = new javax.swing.JCheckBox();
    jPanel1 = new javax.swing.JPanel();

    thePanel.setBackground(new java.awt.Color(255, 204, 204));
    thePanel.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        thePanelPropertyChange(evt);
      }
    });
    thePanel.setLayout(null);

    jButton1.setText("jButton1");
    jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        jButton1MouseClicked(evt);
      }
      public void mouseEntered(java.awt.event.MouseEvent evt) {
        jButton1MouseEntered(evt);
      }
      public void mouseExited(java.awt.event.MouseEvent evt) {
        jButton1MouseExited(evt);
      }
      public void mousePressed(java.awt.event.MouseEvent evt) {
        jButton1MousePressed(evt);
      }
      public void mouseReleased(java.awt.event.MouseEvent evt) {
        jButton1MouseReleased(evt);
      }
    });
    jButton1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
      public void mouseDragged(java.awt.event.MouseEvent evt) {
        jButton1MouseDragged(evt);
      }
      public void mouseMoved(java.awt.event.MouseEvent evt) {
        jButton1MouseMoved(evt);
      }
    });
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton1ActionPerformed(evt);
      }
    });
    jButton1.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        jButton1FocusGained(evt);
      }
    });
    thePanel.add(jButton1);
    jButton1.setBounds(0, 0, 100, 70);

    jButton2.setText("show num");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton2ActionPerformed(evt);
      }
    });
    thePanel.add(jButton2);
    jButton2.setBounds(100, 0, 120, 70);

    theLabel.setText("jLabel1");
    thePanel.add(theLabel);
    theLabel.setBounds(30, 230, 157, 68);

    jButton3.setText("jButton3");
    jButton3.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
      public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
        jButton3MouseWheelMoved(evt);
      }
    });
    jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        jButton3MouseClicked(evt);
      }
    });
    jButton3.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        jButton3StateChanged(evt);
      }
    });
    jButton3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton3ActionPerformed(evt);
      }
    });
    jButton3.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        jButton3PropertyChange(evt);
      }
    });
    thePanel.add(jButton3);
    jButton3.setBounds(160, 130, 150, 90);

    jTextField1.addCaretListener(new javax.swing.event.CaretListener() {
      public void caretUpdate(javax.swing.event.CaretEvent evt) {
        jTextField1CaretUpdate(evt);
      }
    });
    jTextField1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jTextField1ActionPerformed(evt);
      }
    });
    jTextField1.addInputMethodListener(new java.awt.event.InputMethodListener() {
      public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
        jTextField1CaretPositionChanged(evt);
      }
      public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
        jTextField1InputMethodTextChanged(evt);
      }
    });
    jTextField1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        jTextField1PropertyChange(evt);
      }
    });
    jTextField1.addVetoableChangeListener(new java.beans.VetoableChangeListener() {
      public void vetoableChange(java.beans.PropertyChangeEvent evt)throws java.beans.PropertyVetoException {
        jTextField1VetoableChange(evt);
      }
    });
    thePanel.add(jTextField1);
    jTextField1.setBounds(10, 80, 140, 40);

    jCheckBox1.setText("jCheckBox1");
    jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jCheckBox1ActionPerformed(evt);
      }
    });
    thePanel.add(jCheckBox1);
    jCheckBox1.setBounds(160, 80, 81, 23);

    jPanel1.setOpaque(false);

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 100, Short.MAX_VALUE)
    );
    jPanel1Layout.setVerticalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 100, Short.MAX_VALUE)
    );

    thePanel.add(jPanel1);
    jPanel1.setBounds(20, 140, 100, 100);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(thePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(thePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
    );
  }// </editor-fold>//GEN-END:initComponents

    private void jButton1MouseEntered(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MouseEntered
    {//GEN-HEADEREND:event_jButton1MouseEntered
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton1MouseEntered

    private void jButton1FocusGained(java.awt.event.FocusEvent evt)//GEN-FIRST:event_jButton1FocusGained
    {//GEN-HEADEREND:event_jButton1FocusGained
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton1FocusGained

    private void jButton1MouseExited(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MouseExited
    {//GEN-HEADEREND:event_jButton1MouseExited
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton1MouseExited

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MouseClicked
    {//GEN-HEADEREND:event_jButton1MouseClicked
      // TODO add your handling code here:
      System.out.println("click count: " + evt.getClickCount());
    }//GEN-LAST:event_jButton1MouseClicked

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
    {//GEN-HEADEREND:event_jButton1ActionPerformed
      // TODO add your handling code here:
      String test = "hey dude";
      jButton1.setText("<html>"+test+"<br>"+"swing button"+"</html>");
      JLabel blah = new JLabel("What The Hell?");
      Font f = blah.getFont();
      Graphics g = thePanel.getGraphics();
      FontMetrics fm = g.getFontMetrics(f);
      Rectangle2D stringSize = fm.getStringBounds(blah.getText(), g);
      blah.setSize((int)stringSize.getWidth(), (int)stringSize.getHeight());
      thePanel.add(blah);
      blah.setLocation(randGen.nextInt(thePanel.getSize().width), randGen.nextInt(thePanel.getSize().height));
      System.out.println(blah.getLocation().x);
      System.out.println(blah.getLocation().y);
      System.out.println(blah.getSize());
      blah.setVisible(true);
      thePanel.updateUI();
      thePanel.repaint();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton1MousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MousePressed
    {//GEN-HEADEREND:event_jButton1MousePressed
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton1MousePressed

    private void jButton1MouseDragged(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MouseDragged
    {//GEN-HEADEREND:event_jButton1MouseDragged
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton1MouseDragged

    private void jButton1MouseMoved(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MouseMoved
    {//GEN-HEADEREND:event_jButton1MouseMoved
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton1MouseMoved

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton2ActionPerformed
    {//GEN-HEADEREND:event_jButton2ActionPerformed
      // TODO add your handling code here:
      System.out.println(thePanel.getComponentCount());
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1MouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MouseReleased
    {//GEN-HEADEREND:event_jButton1MouseReleased
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton1MouseReleased

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton3ActionPerformed
    {//GEN-HEADEREND:event_jButton3ActionPerformed
      // TODO add your handling code here:
      theLabel.setText("<html>" + "<p>" + "swing pdf" + "<p>" + "</html>");
      thePanel.setBackground(new Color(123, 212, 89));
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton3MouseWheelMoved(java.awt.event.MouseWheelEvent evt)//GEN-FIRST:event_jButton3MouseWheelMoved
    {//GEN-HEADEREND:event_jButton3MouseWheelMoved
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton3MouseWheelMoved

    private void jTextField1PropertyChange(java.beans.PropertyChangeEvent evt)//GEN-FIRST:event_jTextField1PropertyChange
    {//GEN-HEADEREND:event_jTextField1PropertyChange
      // TODO add your handling code here:
      System.out.println(jTextField1.getText());
    }//GEN-LAST:event_jTextField1PropertyChange

    private void jTextField1VetoableChange(java.beans.PropertyChangeEvent evt)throws java.beans.PropertyVetoException//GEN-FIRST:event_jTextField1VetoableChange
    {//GEN-HEADEREND:event_jTextField1VetoableChange
      // TODO add your handling code here:
      System.out.println(jTextField1.getText());
    }//GEN-LAST:event_jTextField1VetoableChange

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jTextField1ActionPerformed
    {//GEN-HEADEREND:event_jTextField1ActionPerformed
      // TODO add your handling code here:
      System.out.println(jTextField1.getText());
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jTextField1InputMethodTextChanged(java.awt.event.InputMethodEvent evt)//GEN-FIRST:event_jTextField1InputMethodTextChanged
    {//GEN-HEADEREND:event_jTextField1InputMethodTextChanged
      // TODO add your handling code here:
      System.out.println(jTextField1.getText());
    }//GEN-LAST:event_jTextField1InputMethodTextChanged

    private void jTextField1CaretPositionChanged(java.awt.event.InputMethodEvent evt)//GEN-FIRST:event_jTextField1CaretPositionChanged
    {//GEN-HEADEREND:event_jTextField1CaretPositionChanged
      // TODO add your handling code here:
      System.out.println(jTextField1.getText());
    }//GEN-LAST:event_jTextField1CaretPositionChanged

    private void jTextField1CaretUpdate(javax.swing.event.CaretEvent evt)//GEN-FIRST:event_jTextField1CaretUpdate
    {//GEN-HEADEREND:event_jTextField1CaretUpdate
      // TODO add your handling code here:
      System.out.println(jTextField1.getText());
    }//GEN-LAST:event_jTextField1CaretUpdate

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jCheckBox1ActionPerformed
    {//GEN-HEADEREND:event_jCheckBox1ActionPerformed
      // TODO add your handling code here:
      System.out.println("pressed");
    }//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jButton3PropertyChange(java.beans.PropertyChangeEvent evt)//GEN-FIRST:event_jButton3PropertyChange
    {//GEN-HEADEREND:event_jButton3PropertyChange
      // TODO add your handling code here:
      
    }//GEN-LAST:event_jButton3PropertyChange

    private void jButton3StateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_jButton3StateChanged
    {//GEN-HEADEREND:event_jButton3StateChanged
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton3StateChanged

    private void thePanelPropertyChange(java.beans.PropertyChangeEvent evt)//GEN-FIRST:event_thePanelPropertyChange
    {//GEN-HEADEREND:event_thePanelPropertyChange
      // TODO add your handling code here:
      System.out.println("PANEL CHANGED");
    }//GEN-LAST:event_thePanelPropertyChange

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton3MouseClicked
    {//GEN-HEADEREND:event_jButton3MouseClicked
      // TODO add your handling code here:
    }//GEN-LAST:event_jButton3MouseClicked


  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton jButton1;
  private javax.swing.JButton jButton2;
  private javax.swing.JButton jButton3;
  private javax.swing.JCheckBox jCheckBox1;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JTextField jTextField1;
  private javax.swing.JLabel theLabel;
  private javax.swing.JPanel thePanel;
  // End of variables declaration//GEN-END:variables
  private Random randGen = new Random();
}
